/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mabi.frontend.appbuilder;

import com.mabi.frontend.FrontEndApp;
import com.mabi.modular.runtime.application.ILayoutApplier;
import com.mabi.modular.runtime.module.contributions.zones.Zone;
import com.vaadin.ui.Component;
import com.vaadin.ui.CustomLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
import com.vaadin.ui.SplitPanel;
import com.vaadin.ui.VerticalLayout;
import java.util.List;

/**
 * 
 * @author Justo Disla
 */
public class BasicGuiBuilder implements ILayoutApplier {

    @Override
    public CustomLayout buildGui(CustomLayout layout, List<Zone> zones, Component[] components) {
        Zone headerSubZone = new Zone();
        headerSubZone.setDebugId(FrontEndApp.HEADER_SUB_ZONE);
        SplitPanel eastAndContentZones = new SplitPanel();
        eastAndContentZones.setOrientation(SplitPanel.ORIENTATION_HORIZONTAL);
        VerticalLayout centerContainer = new VerticalLayout();
        Zone westSubZone = new Zone();
        westSubZone.setDebugId(FrontEndApp.WEST_SUB_ZONE);
        Zone contentSubZone = new Zone();
        contentSubZone.setDebugId(FrontEndApp.CENTER_SUB_ZONE);
        Zone southSubZone = new Zone();
        southSubZone.setDebugId(FrontEndApp.SOUTH_SUB_ZONE);
        //Assemble
        eastAndContentZones.addComponent(westSubZone);
        eastAndContentZones.addComponent(contentSubZone);
        centerContainer.addComponent(buildNavigation());
        eastAndContentZones.setMargin(false, false, false, false);
        centerContainer.addComponent(eastAndContentZones);
        layout.addComponent(headerSubZone, FrontEndApp.HEADER_SUB_ZONE);

        layout.addComponent(centerContainer, FrontEndApp.CENTER_SUB_ZONE);
        layout.addComponent(southSubZone, FrontEndApp.FOOTER_ZONE);
        //Set dimensions
        //        headerSubZone.setHeight(80f, Layout.UNITS_PIXELS);
        centerContainer.setHeight(300f, Layout.UNITS_PIXELS);
        centerContainer.setSpacing(false);


        westSubZone.setSizeFull();
        contentSubZone.setSizeFull();
        eastAndContentZones.setSplitPosition(200, Layout.UNITS_PIXELS);
        southSubZone.setHeight(70f, Layout.UNITS_PIXELS);
        //Feed test
        southSubZone.addComponent(new Label(FrontEndApp.SOUTH_SUB_ZONE));
        
        return layout;
    }

    private Component buildNavigation() {
        return null;
    }

   
    
}
